﻿<div ms-controller="KQTj">

    <!-- 按条件选择 -->
    <div class="tab-filter-type">

        <div class="oh">
            <h5 class="pull-left tr">创建时间：</h5>
            <ul class="tab-type ft14">
                <li><span class="active" ms-click="SelectTime('')">全部</span></li>
                <li ms-click="SelectTime('1')"><span>近一周</span></li>
                <li ms-click="SelectTime('2')"><span>近一月</span></li>
                <li>
                    <span ms-click="SelectTime('3','1')">自定义</span>
                    <div class="pull-right ml10 zdy-text c999" ms-visible="curXJTime=='3'">
                        <input type="text" class="szhl_form_date_mon szhl_require null" ms-duplex="starTime">
                        -
                        <input type="text" class="szhl_form_date_mon szhl_require null" ms-duplex="endTime">
                        <input type="button" ms-click="SelectTime('3')" value="确定" style="width: 50px; background-color: #12B8F6; color: #ffffff" />
                    </div>
                </li>
            </ul>
        </div>
        <!-- 搜索 -->
        <div class="oh">
            <h5 class="pull-left tr">自定义搜索：</h5>
            <ul class="tab-type ft14" ms-if="UserCustomData.size()>0">
                <li ms-repeat-item="UserCustomData" ms-click="selectCustom(item.DataContent)"><span>{{item.DataContent}}<i class="iconfont icon-chenghao-copy" ms-click="DelCustomData(item,$event)"></i></span></li>
            </ul>
            <div class="input-group ml15" style="width: 395px; float: left;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索姓名,部门" style="height: 30px"> 
            </div>
            <span class="btn btn-info" ms-click="GetLIST()" style="float: left; height: 30px;width:100px">搜索</span>

        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display: none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->
    <div class="default-tab ft14 pt20">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc width-70">
                        序号
                    </th>
                    <th>部门</th>
                    <th>姓名</th>
                    <th style="width: 400px">签到</th>
                    <th style="width: 400px">签退</th> 
                    <th>星期</th> 
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="ListData" ms-on-mouseover="mouseover" ms-on-mouseout="mouseout">
                    <td class="tc">
                        {{$index+1+page.pagecount*(page.pageindex-1)}}
                    </td>
                    <td>{{el.KQBranch}}</td>
                    <td>{{ComFunJS.convertuser(el.KQUser)}}</td>
                    <td><span ms-visible="el.KQDate" ms-class-1="text-danger:el.Status==1">{{el.KQDate|date('yyyy-MM-dd HH:mm')}}<label ms-if="el.Position">【{{el.Position}}】</label></span><span ms-visible="!el.KQDate">未签退</span></td>
                    <td><span ms-visible="el.QTDate" ms-class-1="text-danger:el.QTStatus==2">{{el.QTDate|date('yyyy-MM-dd HH:mm')}}<label ms-if="el.QTPosition">【{{el.QTPosition}}】</label></span><span ms-visible="!el.QTDate">未签退</span></td> 
                    <td>{{WeekData[el.WeekDay]}}</td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull">
                    <td class="tc"></td>
                    <td>暂无数据</td>
                </tr>
            </tfoot>
        </table>
        <div class="fy-list">

            <div id="pageDiv" ms-if="ListData.size()!=0" class="pull-right"></div>
            <div class="pull-right" ms-if="ListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                选择每页条数
                <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                    <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                </select>
            </div>

        </div>



    </div>
</div>

<script>

    var tempindex = avalon.define({
        $id: "KQTj",
        curXJType: "",
        curXJTime: "",
        starTime: "",
        endTime: "",
        WeekData: [ "星期日","星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        SelectTime: function (type, item) {
            tempindex.curXJTime = type;
            if (!item) {
                if (type == '3') {
                    var a = (Date.parse(tempindex.starTime) - Date.parse(tempindex.endTime)) / 3600 / 1000;
                    if (a > 0) {
                        ComFunJS.winwarning("开始时间不能大于结束时间");
                    } else {
                        tempindex.GetLIST();
                    }
                } else {
                    tempindex.starTime = "";
                    tempindex.endTime = "";
                    tempindex.GetLIST();
                }
            }
        },
        InitWigetData: function () {
            tempindex.GetLIST();
            ComFunJS.initForm();
        },

        GetLIST: function () {
            model.page.pageindex = 1;
            model.ListData.clear();
            $.getJSON('/API/VIEWAPI.ashx?Action=KQGL_GETKQJLLIST',
                {
                    p: 1,
                    P2: model.search.searchcontent,
                    pagecount: model.page.pagecount,
                    time: tempindex.curXJTime,
                    starTime: tempindex.starTime,
                    endTime: tempindex.endTime
                }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.ListData.pushArray(resultData.Result);
                        if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                        model.page.total = resultData.Result1;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //
                            curr: 1, //初始化当前页
                            skin: 'molv',
                            jump: function (e) { //触发分页后的回调
                                if (e.curr != model.page.pageindex) {
                                    $.getJSON('/API/VIEWAPI.ashx?Action=KQGL_GETKQJLLIST', { p: e.curr, P2: model.search.searchcontent, pagecount: model.page.pagecount, time: tempindex.curXJTime, starTime: tempindex.starTime, endTime: tempindex.endTime }, function (resultData) {
                                        if (resultData.ErrorMsg == "") {

                                            model.ListData.clear();
                                            model.ListData.pushArray(resultData.Result);
                                        }
                                    })
                                    model.page.pageindex = e.curr;
                                }
                            }
                        });
                    }
                })
        },

    })
</script>
